package xin.marcher.module.message.converter;

import org.mapstruct.Mapper;
import org.mapstruct.Mapping;
import org.mapstruct.Mappings;
import xin.marcher.module.common.cache.MessageCache;
import xin.marcher.module.common.message.DataChangeMessage;
import xin.marcher.module.message.domain.bo.DataChangeMessageConfigBO;
import xin.marcher.module.message.domain.bo.DataMessageBO;
import xin.marcher.module.message.domain.entity.DataChangeMessageConfigDO;
import xin.marcher.module.message.domain.entity.DataMessageDetailDO;
import xin.marcher.module.message.domain.entity.DataRefreshDetailDO;

import java.util.List;

/**
 * 消息相关对象克隆
 */
@Mapper(componentModel = "spring")
public interface DataMessageConverter {

    /**
     * 对象克隆
     *
     * @param dataMessageBO
     * @return
     */
    DataMessageDetailDO converterDO(DataMessageBO dataMessageBO);

    /**
     * 对象克隆
     *
     * @param dataMessageDetailDO
     * @return
     */
    DataMessageBO converterBO(DataMessageDetailDO dataMessageDetailDO);

    /**
     * 对象克隆
     *
     * @param dataMessageBO
     * @return
     */
    DataChangeMessage converter(DataMessageBO dataMessageBO);

    /**
     * 对象克隆
     *
     * @param dataChangeMessageConfigDO
     * @return
     */
    DataChangeMessageConfigBO converterBO(DataChangeMessageConfigDO dataChangeMessageConfigDO);

    /**
     * 集合克隆
     *
     * @param messageConfigByListenId
     * @return
     */
    List<DataChangeMessageConfigBO> converterBOList(List<DataChangeMessageConfigDO> messageConfigByListenId);

    /**
     * 集合克隆
     *
     * @param dataMessageBOS
     * @return
     */
    List<DataMessageDetailDO> converterDOList(List<DataMessageBO> dataMessageBOS);

    /**
     * 对象克隆
     *
     * @param dataChangeMessage
     * @return
     */
    @Mappings({
            @Mapping(target = "tableDataJson", ignore = true),
            @Mapping(target = "diffDataArr", ignore = true)
    })
    DataMessageBO converterBO(DataChangeMessage dataChangeMessage);


    /**
     * 对象克隆
     *
     * @param dataRefreshDetailDO
     * @return
     */
    MessageCache converter(DataRefreshDetailDO dataRefreshDetailDO);
}
